<?php
session_start();
include 'objects/User.inc';
if (isset($_SESSION['user'])) {
    $user = unserialize($_SESSION['user']);
} else {
    $user = new User();
}
if (!$user->isLogged()) {
    header("Location: index.php");
    exit();
}

include_once 'objects/Cliente.inc';

if (isset($_GET['id']))
    $obj = Cliente::EId($_GET['id']);
else
    $obj = new Cliente();
?><!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Agregar Cliente</title>
        <link rel="stylesheet" type="text/css" href="css/basic.css" />
        <script type="text/javascript" src="script/main.js"></script>
        <style type="text/css">
            body {
                background-color: #CCC;
            }
            body,td,th {
                color: #000;
                text-align: center;
                font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
            }
            table#form {
                text-align: center;
                color: #000;
            }
        </style>
    </head>
    <body>
        <input id="tmp" type="hidden">
        <img alt="logo2" src="img/boulevard.jpg" style="margin-top: 3em;"/>
        <?php
        if (isset($_COOKIE['msg'])) {
            echo "<p id=\"msg\" class=\"msg\">" . $_COOKIE['msg'] . "</p>";
            setcookie("msg", "", time() - 3600);
        } else {
            echo "<p id=\"msg\" class=\"error\">" . $obj->msg . "</p>";
        }
        ?>
        <table width="629" cellspacing="1" cellpadding="3" border="0" align='center'>
            <tr>
                <td width="621" bgcolor="#CA0000"><div align="center"><b><font color="#FFFFFF" size="3" face="verdana, arial, helvetica">AGREGAR CLIENTE</font></b></div></td>
            <tr>
                <td height="238" bgcolor="#F5ECB9">
                    <table width="700" border="0" id='form'>
                        <tr>
                            <th width="160" scope="row"><label>Codigo:</label></th>
                            <td width="457"><label><b><?php echo $obj->getCode(); ?></b></label></td>
                        </tr>
                        <tr>
                            <th width="160" scope="row"><label>Nombre:</label></th>
                            <td width="457"><input type="hidden" value='<?php echo $obj->encodeId(); ?>' id='formid' />
                                <span><input name="cliente" type="text" id="cliente" size="50"  value="<?php echo $obj->cliente; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Dui:</label></th>
                            <td><span><input name="dui" type="text" id="dui" size="50"  value="<?php echo $obj->dui; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Dirección:</label></th>
                            <td><span><input name="direccion" type="text" id="direccion" size="50"  value="<?php echo $obj->direccion; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Empresa:</label></th>
                            <td><span><input name="nombre_empresa" type="text" id="nombre_empresa" size="50" value="<?php echo $obj->nombre_empresa; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Numero de Registro:</label></th>
                            <td><span><input name="numero_registro" type="text" id="numero_registro" size="50" value="<?php echo $obj->numero_registro; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Teléfono</label></th>
                            <td><span><input name="telefono_cliente" type="text" id="telefono_cliente" size="50" value="<?php echo $obj->telefono_cliente; ?>"/></span></td>
                        </tr>
                        <tr>
                            <th scope="row"><label>Correo Electrónico:</label></th>
                            <td><span><input name="mail" type="text" id="mail" size="50" value="<?php echo $obj->mail; ?>" /></span></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br><br><br>
        <input type="button" name="guardar" id="guardar" value="Guardar" onclick="processForm('cliente');"/>
        <input type="button" name="button" id="button" value="Borrar" onclick="window.location = 'form_cliente.php'"/>
        <input type="button" name="cancelar" id="volver" value="Volver" onclick="window.location = 'menu.php';" style="margin-bottom: 3em;"/>
        <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-width: 0; border-color: #111111; height: 53px" width="100%" id="AutoNumber3">
            <tr>
                <td width="100%" height="26" style="border-style: none; border-width: medium" bgcolor="#CA0000">
                    <p align="center"><b><font face="Arial" size="1" color="#000000">Proyectos Informaticos II /2013</font></b>
                </td>
            </tr>
        </table>
    </body>
</html>
